package com.lgrglw.common.spring;

import java.io.InputStream;
import java.util.Properties;

/**
 * 获取spring配置中加载的键值对
 * @author liwei
 *
 */
public class PropertyOper {

	private static PropertyOper oper;

	private static Properties pro;

	private static final String filePath = "resource/dataSource.properties";
	
	private PropertyOper() {
		InputStream proIn = PropertyOper.class.getClassLoader().getResourceAsStream(filePath);
		pro = new Properties();
		try {
			pro.load(proIn);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static  PropertyOper getInstance(){
		if(oper==null){
			oper=new PropertyOper(); 
		}
		return oper;
	}

	public String getValue(String key){
		return pro.getProperty(key);
	}
	/**
	 * 返回项目中存放索引的位置
	 * @return
	 */
	public String getIndexDir(){
		return pro.getProperty("compass.index");
	}
}
